﻿'######################################################################################################################################
'# CLASSE PRINCIPALE:
'#  - Paramétrage du plugin
'#  - Creation des objets pour les skins
'#  - Creation des objets pour les classes
'#  - Capture des evenements périphériques
'######################################################################################################################################

Imports MediaPortal.GUI.Library
Imports MediaPortal.Dialogs
Imports MediaPortal.Profile
Imports MediaPortal.Player
Imports MediaPortal.Common.Utils

<Assembly: CompatibleVersion("1.1.6.27644")> 

Public Class Plugin
    Inherits GUIWindow
    Implements ISetupForm
    Public Proxy As Boolean = True

    '######################################################################################################################################
    '# Parametrage du plugin
    '######################################################################################################################################
    Public Overrides Property GetID() As Integer
        Get
            ' Obligatoire dans le cadre d'un plugin Window (mettre le même ID que pour la fonction GetWindowId)
            Return 5757
        End Get
        Set(ByVal value As Integer)
        End Set
    End Property

    Public Function Author() As String Implements MediaPortal.GUI.Library.ISetupForm.Author
        'Nom de l'auteur du plugin
        Return "b150n"
    End Function

    Public Function CanEnable() As Boolean Implements MediaPortal.GUI.Library.ISetupForm.CanEnable
        'Permettre l'activaction/désactivation du plugin
        Return True
    End Function

    Public Function DefaultEnabled() As Boolean Implements MediaPortal.GUI.Library.ISetupForm.DefaultEnabled
        'Activer le plugin par défaut
        Return True
    End Function

    Public Function Description() As String Implements MediaPortal.GUI.Library.ISetupForm.Description
        'Description du plugin
        Return "Simple Media Center v0.16"
    End Function

    Public Function GetHome(ByRef strButtonText As String, ByRef strButtonImage As String, ByRef strButtonImageFocus As String, ByRef strPictureImage As String) As Boolean Implements MediaPortal.GUI.Library.ISetupForm.GetHome
        'Texte du bouton plugin sur la page d'accueil
        strButtonText = PluginName()
        strButtonImage = String.Empty
        strButtonImageFocus = String.Empty
        strPictureImage = String.Empty
        'Rendre visible le plugin sur la page d'accueil
        Return True
    End Function

    Public Function GetWindowId() As Integer Implements MediaPortal.GUI.Library.ISetupForm.GetWindowId
        'Identifiant unique pour le plugin (a choisir)
        Return 5757
    End Function

    Public Function HasSetup() As Boolean Implements MediaPortal.GUI.Library.ISetupForm.HasSetup
        'Activer le paramétrage du plugin
        Return False
    End Function

    Public Function PluginName() As String Implements MediaPortal.GUI.Library.ISetupForm.PluginName
        'Nom du Plugin
        Return "SMC Video"
    End Function

    Public Sub ShowPlugin() Implements MediaPortal.GUI.Library.ISetupForm.ShowPlugin
        'Affichage du parametrage du plugin
    End Sub

    Public Overloads Overrides Function Init() As Boolean
        'On charge l'interface du plugin
        Return Load(GUIGraphicsContext.Skin & "\SMC.xml")
    End Function
    '######################################################################################################################################

    '######################################################################################################################################
    '# Creation des references Skin
    '######################################################################################################################################
    <SkinControlAttribute(2)> Public SKINIMG_Fond_Ecran As GUIImage = Nothing
    <SkinControlAttribute(3)> Public SKINIMG_Jaquette As GUIImage = Nothing
    <SkinControlAttribute(4)> Public SKINTXT_Synopsis As GUITextScrollUpControl = Nothing
    <SkinControlAttribute(5)> Public SKINLBL_Heure As GUILabelControl = Nothing
    <SkinControlAttribute(6)> Public SKINIMG_Curseur As GUIImage = Nothing
    <SkinControlAttribute(7)> Public SKINIMG_Page_Haut As GUIImage = Nothing
    <SkinControlAttribute(8)> Public SKINIMG_Page_Bas As GUIImage = Nothing
    <SkinControlAttribute(9)> Public SKINLBL_Titre As GUILabelControl = Nothing

    <SkinControlAttribute(10)> Public SKINIMG_FondTitre As GUIImage = Nothing
    <SkinControlAttribute(11)> Public SKINIMG_FondHeure As GUIImage = Nothing
    <SkinControlAttribute(12)> Public SKINIMG_BordJaquette As GUIImage = Nothing

    <SkinControlAttribute(100)> Public SKINIMG_Separateur00 As GUIImage = Nothing
    <SkinControlAttribute(101)> Public SKINIMG_Type00 As GUIImage = Nothing
    <SkinControlAttribute(102)> Public SKINLBL_Texte00 As GUILabelControl = Nothing
    <SkinControlAttribute(103)> Public SKINIMG_Vu00 As GUIImage = Nothing

    <SkinControlAttribute(110)> Public SKINIMG_Separateur01 As GUIImage = Nothing
    <SkinControlAttribute(111)> Public SKINIMG_Type01 As GUIImage = Nothing
    <SkinControlAttribute(112)> Public SKINLBL_Texte01 As GUILabelControl = Nothing
    <SkinControlAttribute(113)> Public SKINIMG_Vu01 As GUIImage = Nothing

    <SkinControlAttribute(120)> Public SKINIMG_Separateur02 As GUIImage = Nothing
    <SkinControlAttribute(121)> Public SKINIMG_Type02 As GUIImage = Nothing
    <SkinControlAttribute(122)> Public SKINLBL_Texte02 As GUILabelControl = Nothing
    <SkinControlAttribute(123)> Public SKINIMG_Vu02 As GUIImage = Nothing

    <SkinControlAttribute(130)> Public SKINIMG_Separateur03 As GUIImage = Nothing
    <SkinControlAttribute(131)> Public SKINIMG_Type03 As GUIImage = Nothing
    <SkinControlAttribute(132)> Public SKINLBL_Texte03 As GUILabelControl = Nothing
    <SkinControlAttribute(133)> Public SKINIMG_Vu03 As GUIImage = Nothing

    <SkinControlAttribute(140)> Public SKINIMG_Separateur04 As GUIImage = Nothing
    <SkinControlAttribute(141)> Public SKINIMG_Type04 As GUIImage = Nothing
    <SkinControlAttribute(142)> Public SKINLBL_Texte04 As GUILabelControl = Nothing
    <SkinControlAttribute(143)> Public SKINIMG_Vu04 As GUIImage = Nothing

    <SkinControlAttribute(150)> Public SKINIMG_Separateur05 As GUIImage = Nothing
    <SkinControlAttribute(151)> Public SKINIMG_Type05 As GUIImage = Nothing
    <SkinControlAttribute(152)> Public SKINLBL_Texte05 As GUILabelControl = Nothing
    <SkinControlAttribute(153)> Public SKINIMG_Vu05 As GUIImage = Nothing

    <SkinControlAttribute(160)> Public SKINIMG_Separateur06 As GUIImage = Nothing
    <SkinControlAttribute(161)> Public SKINIMG_Type06 As GUIImage = Nothing
    <SkinControlAttribute(162)> Public SKINLBL_Texte06 As GUILabelControl = Nothing
    <SkinControlAttribute(163)> Public SKINIMG_Vu06 As GUIImage = Nothing

    <SkinControlAttribute(170)> Public SKINIMG_Separateur07 As GUIImage = Nothing
    <SkinControlAttribute(171)> Public SKINIMG_Type07 As GUIImage = Nothing
    <SkinControlAttribute(172)> Public SKINLBL_Texte07 As GUILabelControl = Nothing
    <SkinControlAttribute(173)> Public SKINIMG_Vu07 As GUIImage = Nothing

    <SkinControlAttribute(180)> Public SKINIMG_Separateur08 As GUIImage = Nothing
    <SkinControlAttribute(181)> Public SKINIMG_Type08 As GUIImage = Nothing
    <SkinControlAttribute(182)> Public SKINLBL_Texte08 As GUILabelControl = Nothing
    <SkinControlAttribute(183)> Public SKINIMG_Vu08 As GUIImage = Nothing

    <SkinControlAttribute(190)> Public SKINIMG_Separateur09 As GUIImage = Nothing
    <SkinControlAttribute(191)> Public SKINIMG_Type09 As GUIImage = Nothing
    <SkinControlAttribute(192)> Public SKINLBL_Texte09 As GUILabelControl = Nothing
    <SkinControlAttribute(193)> Public SKINIMG_Vu09 As GUIImage = Nothing

    <SkinControlAttribute(200)> Public SKINIMG_Separateur10 As GUIImage = Nothing
    <SkinControlAttribute(201)> Public SKINIMG_Type10 As GUIImage = Nothing
    <SkinControlAttribute(202)> Public SKINLBL_Texte10 As GUILabelControl = Nothing
    <SkinControlAttribute(203)> Public SKINIMG_Vu10 As GUIImage = Nothing

    <SkinControlAttribute(210)> Public SKINIMG_Separateur11 As GUIImage = Nothing
    <SkinControlAttribute(211)> Public SKINIMG_Type11 As GUIImage = Nothing
    <SkinControlAttribute(212)> Public SKINLBL_Texte11 As GUILabelControl = Nothing
    <SkinControlAttribute(213)> Public SKINIMG_Vu11 As GUIImage = Nothing

    <SkinControlAttribute(220)> Public SKINIMG_Separateur12 As GUIImage = Nothing
    <SkinControlAttribute(221)> Public SKINIMG_Type12 As GUIImage = Nothing
    <SkinControlAttribute(222)> Public SKINLBL_Texte12 As GUILabelControl = Nothing
    <SkinControlAttribute(223)> Public SKINIMG_Vu12 As GUIImage = Nothing

    <SkinControlAttribute(230)> Public SKINIMG_Separateur13 As GUIImage = Nothing
    <SkinControlAttribute(231)> Public SKINIMG_Type13 As GUIImage = Nothing
    <SkinControlAttribute(232)> Public SKINLBL_Texte13 As GUILabelControl = Nothing
    <SkinControlAttribute(233)> Public SKINIMG_Vu13 As GUIImage = Nothing

    <SkinControlAttribute(240)> Public SKINIMG_Separateur14 As GUIImage = Nothing
    <SkinControlAttribute(241)> Public SKINIMG_Type14 As GUIImage = Nothing
    <SkinControlAttribute(242)> Public SKINLBL_Texte14 As GUILabelControl = Nothing
    <SkinControlAttribute(243)> Public SKINIMG_Vu14 As GUIImage = Nothing

    <SkinControlAttribute(250)> Public SKINIMG_Separateur15 As GUIImage = Nothing
    '######################################################################################################################################

    '######################################################################################################################################
    '# Gestion des évènements clavier
    '######################################################################################################################################
    Public Overloads Overrides Sub OnAction(ByVal action As MediaPortal.GUI.Library.Action)
        Select Case action.wID
            Case MediaPortal.GUI.Library.Action.ActionType.ACTION_MOVE_DOWN
                'Action si on appuye sur la touche BAS
                SMC_Evenements.Peripherique_Bas()
            Case (MediaPortal.GUI.Library.Action.ActionType.ACTION_MOVE_UP)
                'Action si on appuye sur la touche HAUT
                SMC_Evenements.Peripherique_Haut()
            Case MediaPortal.GUI.Library.Action.ActionType.ACTION_SELECT_ITEM
                'Action si on appuye sur la touche ENTRER
                SMC_Evenements.Peripherique_Selectionner()
            Case MediaPortal.GUI.Library.Action.ActionType.ACTION_MOVE_RIGHT
                'Action si on appuye sur la touche DROITE
                SMC_Evenements.Peripherique_Selectionner()
            Case MediaPortal.GUI.Library.Action.ActionType.ACTION_PREV_ITEM
                'Action si on appuye sur la touche RETOUR
                SMC_Evenements.Peripherique_Retour()
            Case MediaPortal.GUI.Library.Action.ActionType.ACTION_MOVE_LEFT
                'Action si on appuye sur la touche GAUCHE
                SMC_Evenements.Peripherique_Retour()
            Case MediaPortal.GUI.Library.Action.ActionType.ACTION_CONTEXT_MENU
                'Action si on appuye sur la touche MENU
                SMC_Evenements.Peripherique_Menu()
        End Select
        MyBase.OnAction(action)
    End Sub

    '######################################################################################################################################
    '# Création des objets au démarrage du plugin
    '######################################################################################################################################
    Public SMC_Skin As Skin
    Public SMC_Configuration As Configuration
    Public SMC_Explorer As Explorer
    Public SMC_Evenements As Evenements
    Public SMC_Horloge As Horloge
    Public SMC_Menu_Contextuel As Menu_Contextuel
    Public SMC_Gestion_XML As Gestion_XML
    Public SMC_Allocine As Allocine
    Public SMC_Lecture As Lecture
    Public Application_chargee As Boolean

    Protected Overrides Sub OnPageLoad()        
        If Not Application_chargee Then
            MediaPortal.GUI.Library.Log.Debug("[SMC] Plugin.vb >> Creation de la class Configuration", "")
            SMC_Configuration = New Configuration
            MediaPortal.GUI.Library.Log.Debug("[SMC] Plugin.vb >> Creation de la class Skin", "")
            SMC_Skin = New Skin(Me)
            MediaPortal.GUI.Library.Log.Debug("[SMC] Plugin.vb >> Creation de la class Explorer", "")
            SMC_Explorer = New Explorer(Me)
            MediaPortal.GUI.Library.Log.Debug("[SMC] Plugin.vb >> Creation de la class Evenements", "")
            SMC_Evenements = New Evenements(Me)
            MediaPortal.GUI.Library.Log.Debug("[SMC] Plugin.vb >> Creation de la class Horloge", "")
            SMC_Horloge = New Horloge(Me)
            MediaPortal.GUI.Library.Log.Debug("[SMC] Plugin.vb >> Creation de la class Menu_Contextuel", "")
            SMC_Menu_Contextuel = New Menu_Contextuel(Me)
            MediaPortal.GUI.Library.Log.Debug("[SMC] Plugin.vb >> Creation de la class Gestion_XML", "")
            SMC_Gestion_XML = New Gestion_XML(Me)
            MediaPortal.GUI.Library.Log.Debug("[SMC] Plugin.vb >> Creation de la class Allocine", "")
            SMC_Allocine = New Allocine(Me)
            MediaPortal.GUI.Library.Log.Debug("[SMC] Plugin.vb >> Creation de la class Lecture", "")
            SMC_Lecture = New Lecture(Me)
            Application_chargee = True
        Else
            SMC_Explorer.EXPLORER_Rafraichir()
        End If
        'SMC ne gere pas le fenetrage, donc si une video est en cours dans SMC alors on l'arrête
        If g_Player.Playing Then
            MediaPortal.GUI.Library.Log.Debug("[SMC] Plugin.vb >> Execution de g_Player.Stop()", "")
            g_Player.Stop()
        End If

        SMC_Skin.GUI_Echelle_Elements()
    End Sub
    '######################################################################################################################################


End Class
